package com.my.controller;


import com.alibaba.fastjson.JSONObject;
import com.my.bean.ResultPage;
import com.my.bean.RoomTime;
import com.my.bean.VoPage;
import com.my.service.RoomTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;
import java.util.Date;

/**
 * <p>
 * 房间档期表 前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2018-09-01
 */
@Controller
@RequestMapping("/roomTime")
public class RoomTimeController {
    @Autowired
    RoomTimeService roomTimeService;

    //房间档期表格
    @RequestMapping("/selectHomeTime")
    @ResponseBody
    public ResultPage<RoomTime> selectHomeTime(Long homeId,VoPage voPage){
        return  roomTimeService.selectMyPage(voPage,homeId);
    }


    //房间档期新增
    @RequestMapping("/insertRoomTime")
    @ResponseBody
    public String  overHome(String param){
        RoomTime roomTime=JSONObject.parseObject(param, RoomTime.class);
        roomTime.setCreateTime(new Date().getTime());
        if(roomTimeService.insert(roomTime)){
            return  "新增成功";
        }
        return   "新增失败";
    }
}
